#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@Author: kindey
@Date: 2025/8/12
@Description: 
"""
import logging
import traceback
from django.views import View
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from apps.utils.response_utils import success_response, error_response
from apps.services.model_services import CatBoostService

@method_decorator(csrf_exempt, name='dispatch')
class TrainCatBoostView(View):
    """
    绘制设备折线图
    """
    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger(__name__)

    def post(self, request):
        try:
            # data = request.Post;
            # model_name = data.get('model_name', None)
            # start_time = data.get('start_time', None)
            # end_time = data.get('end_time', None)
            # dev_id_list = data.get('dev_id_list', None)
            file_path = ''
            CatBoostService.train_model()
            return success_response(data=file_path)
        except Exception as e:
            error_traceback = traceback.format_exc()
            self.logger.error(f"Exception occurred: {str(e)}\nTraceback:\n{error_traceback}")
            return error_response(str(e))
